﻿@model b7.ViewModels.ShoppingCartViewModel

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Shopping.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        // Document.ready -> link up remove event handler
        $(".RemoveLink").click(function () {
            // Get the id from the link
            var recordToDelete = $(this).attr("data-id");
            if (recordToDelete != '') {
                // Perform the ajax post
                $.post("/ShoppingCart/RemoveFromCart", { "id": recordToDelete }, function (data) {
                    // Successful requests get here
                    // Update the page elements
                    if (data.ItemCount == 0) {
                        $('#row-' + data.DeleteId).fadeOut('slow');
                    } else {
                        $('#item-count-' + data.DeleteId).text(data.ItemCount);
                    }
                    $('#cart-total').text(data.CartTotal);
                    $('#update-message').text(data.Message);
                    $('#cart-status').text('Cart (' + data.CartCount + ')');
                });
            }
        });
    });
</script>
<h2><em>Review</em> your cart:</h2>

@*<div id="update-message">
</div>*@
@*@foreach (var item2 in Model.MemberItems)
{*@
<table border="1">
    <tr>
        <th>
            Images
        </th>
        <th>
            Album Name
        </th>
        <th>
            Price (each)
        </th>
        <th>
            Quantity
        </th>
        <th>
            Action
        </th>
    </tr>
    @*@if()*@
    @foreach (var item in Model.CartItems)
    {
        <tr id="row-@item.RecordId">
            <td>
                <img src="../..@Html.DisplayFor(modelItem => item.Sanpham.Anh)" height="60px" width="60px">
            </td>
            <td>
                @Html.ActionLink(item.Sanpham.Name,"chitietsp", "Home", new { id = item.SanphamId }, null)
            </td>
            <td>
                @item.Sanpham.SalePrice
            </td>
            <td id="item-count-@item.RecordId">
                @item.Count
            </td>
            
        </tr>
    }
    <tr>
        <td>
            Total
        </td>
        <td>
        </td>
        
        <td id="cart-total" colspan="2">
            @Model.CartTotal
        </td>
    </tr>
    <tr>
        <td colspan="2">@Html.ActionLink("Back","Index","ShoppingCart")</td>
        <td colspan="2">@Html.ActionLink("Ok","Index","Home")</td>
    </tr>
</table>
   @* }*@